package com.nick.singleton;

/**
 * Created by xiaobao on 2017/7/18.
 * This is the most simple singleton code, it is lazy loading style and thread safe.
 * But at most of the time, this doesn't need to be synchronized.
 * Performance is bad.
 */
public class Singleton2 {
    private static Singleton2 singleton;

    private Singleton2() {
    }
    public static synchronized Singleton2 getInstance() {
        if (singleton == null) {
            singleton = new Singleton2();
        }
        return singleton;
    }
}
